#ifndef FASHIONSTARSERVO_H
#define FASHIONSTARSERVO_H

#include <QSerialPort>
#include <QObject>
#include <QTimer>

enum PackNum
{
    Ping = 1,
    ResetUserData,
    ReadData,
    WriteData,
    ReadBatchData,
    WriteBatchData,
    MoveOnWheelMode,
    MoveOnAngleMode,
    MoveOnDampingMode,
    ReadAngle,
};

class FashionStarServo : public QObject
{
    Q_OBJECT
public:
    explicit FashionStarServo(QObject *parent = nullptr, QSerialPort *serial = nullptr);

signals:

public slots:
    void setAngle(uint8_t id, double angle, uint16_t interval, uint16_t power);
    //void readReigster();
    void onTimeout();
    void onStartTimer();
    void onStopTimer();
    void onReadSerialData();

public:
    uint8_t checksum(uint8_t* data, uint16_t len);

    void readData(uint8_t* data, uint16_t len);
    void execPacket(uint8_t* data);

private:
    QSerialPort *m_serial;
    QTimer *m_timer;
};

#endif // FASHIONSTARSERVO_H
